#pragma once
#include <string>
#include <unordered_map>
#include "glm/glm.hpp"
struct ShaderProgramSource
{
    std::string VertexSource;
    std::string FragmentSource;
};

class Shader
{
private:
    unsigned int m_RendererID;
    std::string m_FilePath;
    std::string m_Vertex_FilePath;
    std::string m_Frag_FilePath;
    std::unordered_map<std::string, int> m_UniformlocationCache;

public:
    Shader(){m_RendererID=-1;};
    Shader(const std::string& filepath);
    Shader(const std::string& Vertex_filepath,const std::string& Frag_filepath);
    ~Shader();
    unsigned int get_ID()
    {
        return m_RendererID;
    }
    void Bind() const;
    void Unbind() const;

    void SetUniform1i(const std::string& name, int value);
    void SetUniform1f(const std::string& name, float value);
    void SetUniform4f(const std::string& name, float v0, float v1, float v2, float v3);
    void SetUniform3f(const std::string& name, float v0, float v1, float v2);
    void SetUniformMat4f(const std::string& name, const glm::mat4& matrix);
private:
    ShaderProgramSource ParseShader(const std::string& filepath);
    ShaderProgramSource ParseShader(const std::string& Vertex_filepath,const std::string& Frag_filepath);
    unsigned int CompileShader(unsigned int type, const std::string& source);
    unsigned int CreateShader(const std::string& vertexShader, const std::string& fragmentShader);
    int GetUniformLocation(const std::string& name);
};